#!/usr/bin/env bash
# extracting options and parameters

# 特殊字符双破折线（--）。shell 会用双破折线来表明选项列表结束。该字符会告诉脚本何时选项结束以及普通参数何时开始。

#./test16.sh -c -a -b test1 test2
#./test16.sh -c -a -b  -- test1 test2


echo
while [ -n "$1" ]; do
	case "$1" in
	-a) echo "Found the -a option" ;;
	-b) echo "Found the -b option" ;;
	-c) echo "Found the -c option" ;;
	--)
		shift
		break
		;;
	*) echo "$1 is not a option" ;;
	esac
	shift
done

count=1
for param in "$@"; do
	echo "Parameter $count: $param"
	count=$((count + 1))
done
